package com.lb.decimal;

import java.math.BigDecimal;
import java.util.Optional;

/**
 * @version 1.0
 * @Author: Edward
 * @Date: 2020/9/16 14:49
 * @Description:
 */
public class DecimalTest {
    public static void main(String[] args) {
        BigDecimal a = BigDecimal.ZERO;
        calc(a);
        System.out.println(a);

        BigDecimal b1 = BigDecimal.valueOf(10);
        BigDecimal b2 = null;
        BigDecimal b3 = BigDecimal.valueOf(10);

        System.out.println(b1.add(Optional.ofNullable(b2).orElse(BigDecimal.ZERO)).add(b3));

    }

    public static void calc(BigDecimal a) {
        a = a.add(new BigDecimal(100.456));
    }
}
